package edu.um.expression;

import java.util.ArrayList;
import java.util.List;

import edu.um.token.Token;
import edu.um.token.TokenKind;

public class Expression extends ArrayList<Token>{

  public Expression(List<Token> tokenList) {
    super(tokenList);
  }

  public Expression() {
    super();
  }

  /**
   *
   * @param kind
   * @return
   */
  public int indexOf(TokenKind kind) {
    int index = 0;
    for (Token token : this) {
      if (token.getKind() == kind ) {
        return index;
      }
      index++;
    }
    return -1;
  }

  public Expression subExpression(int fromIndex, int toIndex) {
    return new Expression (this.subList(fromIndex, toIndex));
  }
  /**
   * Default serial version;
   */
  private static final long serialVersionUID = 1L;

}
